package com.yc;

import com.yc.spring.bbs.bean.Page;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object o, String id) throws BeansException {
        //对象创建之后  初始化对象之前
        //当前方法不做处理
        return o;
    }

    @Override
    public Object postProcessAfterInitialization(Object o, String id) throws BeansException {
        //对象创建之后  初始化对象之后
        if(o instanceof Page){
            Page page = (Page) o;
            page.setTotal(10000);
            return page;
        }
        return o;
    }
}
